package hojadetrabajo_6;

import java.util.*;

public class HuffmanExe
{
    static Heap h; 
    static Huffman huffman;
    private static Scanner input = new Scanner(System.in);
    private static String value;
    private static String codigos[]=new String[100];
    private static char letras[]=new char[100];
    private static int frec[]=new int[100];
    private static boolean success;
    private static int value1, value2;
    static MinMax myHeap = new MinMaxHeap(50);
    
    public static void main(String args[])
	{
                h = new Heap(31); // make a Heap; max size 31
		System.out.print("Ingrese una cadena: ");
                value = input.nextLine();
                System.out.println("Cadena Ingresada: "+value);
                huffman = new Huffman(value);
                codigos=huffman.obtenerCodigos();
                letras=huffman.obtenerCaracteres();
                frec=huffman.obtenerFrecuencia();
                System.out.println("Caracter Frecuencia Codigo");
                for (int i=0;i<codigos.length;i++){
                    if (codigos[i]!=null){
                        System.out.print("    "+letras[i]+"   ");
                        System.out.print("       "+frec[i]+"    ");
                        System.out.println("   "+codigos[i]+"   ");
                        h.insert(frec[i]);
                        myHeap.enqueue(new Integer(frec[i]));
                    }
                    
                }
                //h.displayHeap();
                Integer min = (Integer)myHeap.min();
                Integer max = (Integer)myHeap.max();
                System.out.print(" Minimo " + min + " ");
	}
}
